﻿@namespace BlazorFluentUI.Routing
@inherits FluentUIComponentBase

<LocalCS @bind-Rules=@NavLinkLocalRules />

<li role="listitem"
    class=@($"ms-Nav-navItem {ClassName}")
    style=@Style
    @ref="RootElementReference">
    <div class=@($"ms-Nav-compositeLink {(isExpanded?"is-expanded":"")} {(Disabled?"is-disabled":"")} {(isSelected?"is-selected":"")} {(IsButton?"is-button":"")}")>
        @if (this.ChildContent != null)
        {
            <button class=@($"ms-Nav-chevronButton {ChevronButtonLeftRule.Selector?.SelectorName}") @onclick=@ExpandHandler aria-label=@AriaLabel aria-expanded=@IsExpanded>
                <Icon ClassName="ms-Nav-chevron" IconName="chevron_down" />
            </button>
        }
        <ActionButton 
            ClassName=@($"ms-Nav-link {NavLinkLeftPaddingRule.Selector?.SelectorName} {(IconName != null |IconSrc != null ? "has-icon" : "")}")
            Href=@Url 
            IconName=@IconName 
            IconSrc=@IconSrc 
            Disabled=@Disabled 
            AriaLabel=@AriaLabel 
            OnClick=@ClickHandler
            Command=@Command
            CommandParameter=@CommandParameter>
            <div class="ms-Nav-linkText">@((MarkupString)Name!)</div>
        </ActionButton>
    </div>
    @if (this.IsExpanded)
    {
        <ul role="list" class="ms-Nav-navItems slideDownIn20">
            @ChildContent
        </ul>
    }
</li>